<?php
/* 
* [***********************]
* @author: mazhenyu[houdunwangmzy@163.com]
* @Date:   2014-07-01 19:17:22
* @Last Modified time: 2014-07-02 08:28:10
*/
class ResumeRelationModel extends RelationModel{
	//定义主表名字
	public $table = 'people_resume1';


	public $join = array(
		'people_resume2'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_ONE,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			),
		'people_resume3'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_ONE,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			),
		'people_resume4'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_MANY,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			),
		'people_resume5'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_MANY,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			),
		'people_resume6'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_MANY,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			),
		'people_resume7'	=>	array(
			//表之间的关系
			'type' 			=>	HAS_ONE,
			//从表关联字段
			'foreign_key'	=>	'resume1_reid',
			//主表关联字段
			'parent_key'	=>	'reid'
			)

		);

	/**
	 * [del_resume 删除简历]
	 * @param  [type] $reid [description]
	 * @param  [type] $uid  [description]
	 * @return [type]       [description]
	 */
	public function del_resume($reid,$uid=NULL){

		$where = array(
			'user_uid'	=>	$uid,
			'reid'		=>	$reid
			);
		//为了后台做考虑，应为后台用户想删除谁的就删除谁的
		if(is_null($uid)) unset($where['user_uid']);
		//删除中间表
		K('ResumePos')->del_data($reid);
		//删除第7阶段形象照片
		K('Resume7')->del_pic($reid);
		//删除7张表
		$this->where($where)->delete();
		return true;

		
	}
}
?>
